
import time
import threading

def sing():
    for i in range(5):
        print(" singing ...")
        time.sleep(1)

def dance():
    for i in range(5):
        print(" dancing ...")
        time.sleep(1)

def main():
    t1 = threading.Thread(target=sing,name="sing")
    t2 = threading.Thread(target=dance,name="dance")
    t1.start()
    t2.start()

    time.sleep(2)
    print(threading.enumerate())

    while True:
        # 获取正在运行的线程数量
        length = len(threading.enumerate())
        print("the amount of threads is %s" % length)
        if length <= 1:
            break

        time.sleep(0.5)



if __name__ == "__main__":
    main()